package com.chinasoft.reposearch.util;

import com.chinasoft.reposearch.RepoSearchApplication;
import com.chinasoft.reposearch.service.ElasticService;
import com.chinasoft.reposearch.service.HiveService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SyncElasticSearch {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(RepoSearchApplication.class);
        ElasticService elasticService = context.getBean(ElasticService.class);
        HiveService hiveService = context.getBean(HiveService.class);
        if (!elasticService.ifExistsIndex("repo")){
            elasticService.createIndex("elasticsearch/create_index_repo.json", "repo");
        }
        hiveService.queryForAllList(new String[]{"*"}, "repo_search.repo");
        context.close();
    }
}
